<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>

    <input type="text" id="username" placeholder="账号"><br>
    <input type="password" id="password" placeholder="密码"><br>

    <button id="sub" onclick="login()">登录</button>
    <br>

    <p><span id="msg"></span></p>
    <script>
        function login() {
            let username = $("#username").val();
            let password = $("#password").val();
            $.ajax({
                url: "login",
                type: "POST",
                data: {
                    uName: username,
                    uPwd: password
                },
                success: function (data) {
                    console.log(data);
                    $("#msg").text(data);
                    /*window.location.href = "/index";*/
                },
                error: function (data) {
                    $("#msg").text(data);
                }
            })
        }
    </script>
</body>
</html>